package vista;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class RegistrarCategoria extends javax.swing.JFrame {
	private JPanel panRegistrarCategoria;
	private JLabel jLabel3;
	private JButton btnNuevo;
	private JLabel lblNroCodigo;
	private JComboBox cmbRegistroCat;
	private JButton btnEliminarCa;
	private JButton btnModificarCat;
	private JButton btnIncluirCateg;
	private JTextField txtNombreCat;
	private JLabel jLabel2;
	private JLabel jLabel1;

	/**
	* Auto-generated main method to display this JFrame
	*/
	
	public RegistrarCategoria() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setBackground(new java.awt.Color(0,0,0));
			getContentPane().setLayout(null);
			{
				panRegistrarCategoria = new JPanel();
				getContentPane().add(panRegistrarCategoria);
				panRegistrarCategoria.setLayout(null);
				panRegistrarCategoria.setBounds(12, 74, 374, 161);
				panRegistrarCategoria.setBackground(new java.awt.Color(150,182,35));
				{
					jLabel2 = new JLabel();
					panRegistrarCategoria.add(jLabel2);
					jLabel2.setText("Código:");
					jLabel2.setBounds(35, 21, 77, 14);
					jLabel2.setFont(new java.awt.Font("Purisa",0,14));
				}
				{
					jLabel3 = new JLabel();
					panRegistrarCategoria.add(jLabel3);
					jLabel3.setText("Nombre:");
					jLabel3.setFont(new java.awt.Font("Purisa",0,14));
					jLabel3.setBounds(35, 61, 75, 12);
				}
				{
					txtNombreCat = new JTextField();
					panRegistrarCategoria.add(txtNombreCat);
					txtNombreCat.setBounds(104, 56, 145, 21);
					txtNombreCat.setDragEnabled(true);
					txtNombreCat.setDoubleBuffered(true);
					KeyStroke keyStroke = KeyStroke.getKeyStroke(Character.valueOf(' '), 0);
					txtNombreCat.getInputMap(JComponent.WHEN_FOCUSED).put(keyStroke, "none");
				}
				{
					btnIncluirCateg = new JButton();
					panRegistrarCategoria.add(btnIncluirCateg);
					btnIncluirCateg.setBounds(305, 4, 57, 46);
					btnIncluirCateg.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
					btnIncluirCateg.setOpaque(false);
					btnIncluirCateg.setIcon(new ImageIcon(getClass().getClassLoader().getResource("Imagenes/guardar-incluir.jpg")));
					btnIncluirCateg.setActionCommand("Incluir");
				}
				{
					btnModificarCat = new JButton();
					panRegistrarCategoria.add(btnModificarCat);
					btnModificarCat.setBounds(305, 56, 54, 46);
					btnModificarCat.setOpaque(false);
					btnModificarCat.setIcon(new ImageIcon(getClass().getClassLoader().getResource("Imagenes/guardarcambios.jpg")));
					btnModificarCat.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
					btnModificarCat.setActionCommand("Modificar");
				}
				{
					btnEliminarCa = new JButton();
					panRegistrarCategoria.add(btnEliminarCa);
					btnEliminarCa.setBounds(305, 108, 57, 47);
					btnEliminarCa.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
					btnEliminarCa.setOpaque(false);
					btnEliminarCa.setIcon(new ImageIcon(getClass().getClassLoader().getResource("Imagenes/Eliminar.jpg")));
					btnEliminarCa.setActionCommand("Eliminar");
				}
				{
				
					cmbRegistroCat = new JComboBox();
					panRegistrarCategoria.add(cmbRegistroCat);
					//jComboRegistroCat.setModel(jComboRegistroCatModel);
					cmbRegistroCat.setBounds(104, 98, 145, 21);
					cmbRegistroCat.setActionCommand("ComboSeleccionado");
				}
				{
					lblNroCodigo = new JLabel();
					panRegistrarCategoria.add(lblNroCodigo);
					lblNroCodigo.setFont(new java.awt.Font("Purisa",0,14));
					lblNroCodigo.setBounds(105, 21, 77, 14);
				}
				{
					btnNuevo = new JButton();
					panRegistrarCategoria.add(btnNuevo);
					btnNuevo.setText("Nuevo");
					btnNuevo.setActionCommand("Nuevo");
					btnNuevo.setFont(new java.awt.Font("Purisa",0,10));
					btnNuevo.setBackground(new java.awt.Color(255,255,255));
					btnNuevo.setBounds(180, 18, 69, 21);
					btnNuevo.addActionListener(null);
				}
			}
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1);
				jLabel1.setText("Categoria");
				jLabel1.setBounds(94, 6, 231, 62);
				jLabel1.setFont(new java.awt.Font("Purisa",0,24));
				jLabel1.setForeground(new java.awt.Color(255,255,255));
				jLabel1.setIcon(new ImageIcon(getClass().getClassLoader().getResource("Imagenes/CategoriaBlack.jpg")));
			}
			pack();
			this.setSize(410, 279);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	public void addListener(ActionListener actionListener){
		
		this.btnEliminarCa.addActionListener(actionListener);
		this.btnIncluirCateg.addActionListener(actionListener);
		this.btnModificarCat.addActionListener(actionListener);
		this.cmbRegistroCat.addActionListener(actionListener);
		this.btnNuevo.addActionListener(actionListener);
	}
	public void setNroCodigo(String n){
		this.lblNroCodigo.setText(n);
	}
	public String getNroCodigo(){
		return this.lblNroCodigo.getText();
	}
	public void setTxtNombreCat(String nomb){
		this.txtNombreCat.setText(nomb);
	}
	public String getTxtNombreCat(){
		return this.txtNombreCat.getText();
	}
	public void setComboCategorias(String[] comboModel){
		ComboBoxModel comboCategoriasModel = new DefaultComboBoxModel(comboModel);
		this.cmbRegistroCat.setModel(comboCategoriasModel);
	}
	public String getComboCategorias(){
		return this.cmbRegistroCat.getSelectedItem().toString();
	}
	public void habilitarBotonIncluir(boolean v){
		this.btnIncluirCateg.setEnabled(v);
	}
	public void habilitarBotonModificar(boolean v){
		this.btnModificarCat.setEnabled(v);
	}
	public void habilitarBotonEliminar(boolean v){
		this.btnEliminarCa.setEnabled(v);
	}
	public void mostrarMensaje(String mens){
		JOptionPane.showMessageDialog(this, mens);
	}
}
